package ws.utils.collections.table;

/**
 * LaTex representation of the row.
 *
 * @author Wilson Santos, 36228 <wilson.santos@ua.pt>
 */
public class RowLatex extends Row {

  /**
   * Create new instance from other row.
   *
   * @param row other row.
   */
  public RowLatex(Row row) {
    for (Column col : row.columnList) {
      addColumn(new ColumnLatex(col));
    }
  }

  /**
   * Get LaTex representation of this row.
   *
   * @return LaTex code.
   */
  @Override
  public String toString() {
    String latex = "";

    if (columnCount() > 0) {
      latex += columnList.get(0).toString();
      for (int i = 1; i < columnCount(); ++i) {
        latex += " & " + columnList.get(i).toString();
      }
    }
    latex += " \\\\ \\hline\n";
    return latex;
  }
}
